<template>
	<view :class="isDark?'darkBg':''">
		<cu-custom :bgColor="isDark?'bg-black':'bg-blue'" isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">课表信息</block>
		</cu-custom>
		<view style="height: 545rpx; background-size: cover;  background-position: center;"
			:style="{backgroundImage:isDark?'url(https://web.cloudduolc.cn/image/adblack7.png)':'url(https://web.cloudduolc.cn/image/adwhite5.png)'}">
			<ad unit-id="adunit-b1c61a406515258a" ad-type="video" :ad-theme="isDark?'black':'white'"></ad>
		</view>
		<view :class="isDark?'dark':''" class="margin-bottom-xl">
			<view class="cu-bar  solid-bottom" style="font-weight:bold" :class="isDark?'dark':'bg-white'">
				<view class="action">
					<text class="cuIcon-titles text-blue"></text> 课表信息
				</view>
			</view>
			<view class="margin  padding radius " :class="isDark?'darkIn':'bg-white'">
				<form class="form" @submit="formSubmit">
					<view class="cu-form-group " :class="isDark?'darkIn':'light'">

						<view class="title">查看</view>
						<scroll-view :scroll-top="scrollTop" scroll-y="true"
							style="height: 200px;border:1px solid ;margin:30rpx;padding:30rpx">
							<view class="cu-item " v-for="(val,index) in classNameSeeList" :key="index"
								:class="isDark?'darkIn':'light'" style="margin-top: 10px; margin-left:10px">
								{{val}}
							</view>
							<view v-if="classNameSeeList.length==0" style="margin-top: 10px;">
								查无此班级
							</view>
						</scroll-view>
					</view>
					<view class="cu-form-group " :class="isDark?'darkIn':'light'">

						<view class="title">班级</view>
						<input name="className" placeholder="例如:22物流（中美班）" :value="className"
							@input="searchIcon"></input>

					</view>

					<view class="margin">
						<text style="color: gray;">注意*(填写错误将匹配不到课表)</text>
					</view>
					<view class="margin">
						<text style="color: red;">非新生请勿填写查询</text>
					</view>
					<view class="cu-bar btn-group" :class="isDark?'darkIn':'light'">
						<button class="cu-btn bg-grey round lg" form-type="submit">查询</button>

					</view>
				</form>

			</view>
		</view>
		<view :class="isDark?'dark':''" style="height: 200rpx;"></view>
		<zmm-watermark>

		</zmm-watermark>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				className: '',
				isDark: this.isDark,
				data: {},
				classNameList: [],
				classNameSeeList: []
			}
		},
		onShow() {
			let _this = this
			_this.className = _this.$store.state.className


			_this.$schoolApi.className().then(response => {
				if (response.status == 0) {
					for (var i = 0; i < response.data.length; i++) {
						_this.classNameList.push(response.data[i])
						if (_this.className == null && _this.className == '') {
							var temp = {
								"detail": {
									"value": _this.className
								}
							}
						} else {
							var temp = {
								"detail": {
									"value": "22"
								}
							}
						}
					}
					_this.searchIcon(temp)
				}

				//这里只会在接口是成功状态返回
			})
		},

		methods: {
			searchIcon(e) {
				let key = e.detail.value;
				let _this = this
				_this.classNameSeeList = []
				console.log(key)
				for (var i = 0; i < _this.classNameList.length; i++) {
					if (_this.classNameList[i].indexOf(key) != -1) {
						_this.classNameSeeList.push(_this.classNameList[i])
					}
				}
			},
			formSubmit: function(e) {
				let _this = this
				var formdata = e.detail.value
				uni.showToast({
					icon: 'none',
					title: '保存成功',
					duration: 2000
				});
				_this.$store.commit("className", formdata.className)
				_this.$Router.navigateTo("/pages/school/timetables/index")
			},

		}

	}
</script>

<style>
	.form {
		margin: 10rpx;
	}

	.imgCodeSrc {
		margin-top: 30rpx;
	}

	.viewInput {
		margin-left: 30rpx;
		margin-bottom: 20rpx;
	}

	.uni-form-item .title {
		padding: 20rpx 0;
	}

	.input {
		border: 1px solid #ccc;
		border-radius: 3px;
		margin-right: 20rpx;
		font-size: 17px;
		font-family: "Microsoft soft";
		padding: 7px 7px;
	}
</style>
